﻿
namespace Patterns4Net.PatternEnforcer.Core
{
    using System;
    using System.Diagnostics.Contracts;

    /// <summary>
    /// Generic interfaces and their implementations with the generic parameter constrained to IMemberDefinition or MemberReference 
    /// are used in this namespace. This exception should be used when the implementation gets a member type that it is not 
    /// able to handle.
    /// </summary>
    public class NotSupportedMemberTypeException : ApplicationException
    {
        private const string MessageTemplate =
            @"Member of the type {0} is not supported in generic class {1} (method {2}). {3}";

        public NotSupportedMemberTypeException(Type memberType, string className, string methodName, string additionalInfo = "")
            : base(string.Format(MessageTemplate, memberType.Name, className, methodName, additionalInfo))
        {
            Contract.Requires(memberType != null);
        }
    }
}
